
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>1.3.2-1.5.2 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="4.2.html" />
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" >
            
                <a target="_blank" href="https://github.com/xfl03/CoreModTutor">
            
                    
                    源代码仓库（求star）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="./">
            
                <a href="./">
            
                    
                    目录
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="0.html">
            
                <a href="0.html">
            
                    
                    0 绪论
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" >
            
                <span>
            
                    
                    1 简介
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="1.1.html">
            
                <a href="1.1.html">
            
                    
                    CoreMod
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="1.2.html">
            
                <a href="1.2.html">
            
                    
                    Java虚拟机
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="1.3.html">
            
                <a href="1.3.html">
            
                    
                    Minecraft混淆方式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" >
            
                <span>
            
                    
                    2 Java虚拟机
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" >
            
                <span>
            
                    
                    ClassLoader类加载器
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" >
            
                <span>
            
                    
                    ByteCode字节码
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" >
            
                <span>
            
                    
                    ASM
            
                </span>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" >
            
                <span>
            
                    
                    3 原版 CoreMod
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="3.1.html">
            
                <a href="3.1.html">
            
                    
                    直接修改class文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="3.2.html">
            
                <a href="3.2.html">
            
                    
                    JavaAgent
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="3.3.html">
            
                <a href="3.3.html">
            
                    
                    LaunchWrapper
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="3.4.html">
            
                <a href="3.4.html">
            
                    
                    ModLauncher
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" >
            
                <span>
            
                    
                    4 FML CoreMod
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.7.1" data-path="4.1.html">
            
                <a href="4.1.html">
            
                    
                    1.3.2-1.5.2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="4.2.html">
            
                <a href="4.2.html">
            
                    
                    1.6.1-1.12.2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="4.3.html">
            
                <a href="4.3.html">
            
                    
                    1.13.2-1.14.4
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="5.html">
            
                <a href="5.html">
            
                    
                    5 Mixin
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="5.1.html">
            
                <a href="5.1.html">
            
                    
                    配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="5.2.html">
            
                <a href="5.2.html">
            
                    
                    引导
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="5.3.html">
            
                <a href="5.3.html">
            
                    
                    注入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="5.4.html">
            
                <a href="5.4.html">
            
                    
                    修改
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.5" data-path="5.5.html">
            
                <a href="5.5.html">
            
                    
                    定位
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.6" data-path="5.6.html">
            
                <a href="5.6.html">
            
                    
                    融合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.7" data-path="5.7.html">
            
                <a href="5.7.html">
            
                    
                    扩展
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.8" data-path="5.8.html">
            
                <a href="5.8.html">
            
                    
                    调试
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" >
            
                <span>
            
                    
                    附录
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="附录A.html">
            
                <a href="附录A.html">
            
                    
                    附录A 相关工具下载
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="附录B.html">
            
                <a href="附录B.html">
            
                    
                    附录B 常见Java字节码指令表
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="附录C.html">
            
                <a href="附录C.html">
            
                    
                    附录C 参考资料
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >1.3.2-1.5.2</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="132-152-fml-coremod&#x5927;&#x4E8B;&#x8BB0;">1.3.2-1.5.2 FML CoreMod&#x5927;&#x4E8B;&#x8BB0;</h1>
<ul>
<li>1.3.2 FML&#x91CD;&#x5199;&#x4E86;Mod&#x52A0;&#x8F7D;&#x673A;&#x5236;<ul>
<li>&#x8FD9;&#x4E00;Mod&#x52A0;&#x8F7D;&#x673A;&#x5236;&#x88AB;&#x6301;&#x7EED;&#x4F7F;&#x7528;&#x5230;&#x4E86;1.12.2</li>
<li>&#x52A0;&#x5165;&#x4E86;&#x57FA;&#x4E8E;FML Relauncher&#x7684;CoreMod&#x673A;&#x5236;</li>
</ul>
</li>
</ul>
<h1 id="&#x52A0;&#x8F7D;&#x6D41;&#x7A0B;">&#x52A0;&#x8F7D;&#x6D41;&#x7A0B;</h1>
<p>&#xFF08;&#x5BF9;&#x52A0;&#x8F7D;&#x6D41;&#x7A0B;&#x4E0D;&#x611F;&#x5174;&#x8DA3;&#x7684;&#x8BDD;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x8DF3;&#x8FC7;&#x8FD9;&#x4E00;&#x90E8;&#x5206;&#xFF0C;&#x4EE5;&#x4E0B;&#x4EE3;&#x7801;&#x6765;&#x81EA;1.5.2FML&#xFF09;</p>
<p>&#x975E;&#x5E38;&#x611F;&#x8C22;&#x60A8;&#x80FD;&#x8010;&#x5FC3;&#x770B;&#x5230;&#x672C;&#x7AE0;&#xFF0C;&#x8FD9;&#x4E00;&#x7AE0;&#x7684;&#x4E3B;&#x8981;&#x76EE;&#x7684;&#x662F;&#x4ECE;FML CoreMod&#x7684;&#x8D77;&#x6E90;&#x6765;&#x63A2;&#x7A76;&#x8FD9;&#x4E00;&#x673A;&#x5236;&#x662F;&#x5982;&#x4F55;&#x4E00;&#x8109;&#x76F8;&#x627F;&#x7684;&#x3002;&#x5728;&#x8FD9;&#x4E9B;&#x7248;&#x672C;&#x4E2D;&#xFF0C;&#x6CA1;&#x6709;LaunchWrapper&#x3001;ModLauncher&#x7B49;&#x4E13;&#x95E8;&#x8D1F;&#x8D23;ClassLoader&#x3001;Transformer&#x7684;&#x5E93;&#xFF0C;&#x6240;&#x6709;&#x76F8;&#x5173;&#x7684;&#x884C;&#x4E3A;&#x90FD;&#x9700;&#x8981;FML&#x81EA;&#x884C;&#x5904;&#x7406;&#xFF0C;&#x8FD9;&#x4E9B;&#x7248;&#x672C;&#x7684;&#x5B9E;&#x8DF5;&#x4E5F;&#x4E3A;LaunchWrapper&#x7B49;&#x5E93;&#x7684;&#x8BBE;&#x8BA1;&#x5960;&#x5B9A;&#x4E86;&#x57FA;&#x7840;&#x3002;</p>
<p>Forge&#x4ECE;FML CoreMod&#x8D77;&#x6E90;&#x5F00;&#x59CB;&#x5C31;&#x6CA1;&#x6709;&#x63D0;&#x4F9B;&#x6587;&#x6863;&#x4E0E;&#x6559;&#x7A0B;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x81EA;&#x884C;&#x63A2;&#x7D22;&#x3002;</p>
<p>&#x5728;<a href="https://github.com/MinecraftForge/FML/blob/1.5.1/common/cpw/mods/fml/relauncher/RelaunchLibraryManager.java" target="_blank">RelaunchLibraryManager</a>&#x4E2D;&#xFF0C;FML&#x8FDB;&#x884C;&#x4E86;&#x5982;&#x4E0B;&#x64CD;&#x4F5C;&#xFF1A;</p>
<ul>
<li><p><code>discoverCoreMods</code>&#x65B9;&#x6CD5;&#x4E2D;&#xFF0C;FML&#x4F1A;&#x904D;&#x5386;<code>coremods</code>&#x6587;&#x4EF6;&#x5939;&#x4E2D;&#x7684;&#x6240;&#x6709;jar</p>
<pre><code class="lang-java">File coreMods = setupCoreModDir(mcDir);
FilenameFilter ff = <span class="hljs-keyword">new</span> FilenameFilter()
{
  <span class="hljs-meta">@Override</span>
  <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">boolean</span> <span class="hljs-title">accept</span><span class="hljs-params">(File dir, String name)</span>
  </span>{
      <span class="hljs-keyword">return</span> name.endsWith(<span class="hljs-string">&quot;.jar&quot;</span>);
  }
};
...
<span class="hljs-keyword">for</span> (File coreMod : coreModList)
</code></pre>
</li>
<li><p>&#x968F;&#x540E;&#x8BFB;&#x53D6;jar&#x4E2D;&#x7684;Manifest&#xFF0C;&#x5E76;&#x5224;&#x65AD;&#x662F;&#x5426;&#x5B58;&#x5728;<code>FMLCorePlugin</code></p>
<pre><code class="lang-java">mfAttributes = jar.getManifest().getMainAttributes();
...
String fmlCorePlugin = mfAttributes.getValue(<span class="hljs-string">&quot;FMLCorePlugin&quot;</span>);
<span class="hljs-keyword">if</span> (fmlCorePlugin == <span class="hljs-keyword">null</span>)
{
  FMLRelaunchLog.severe(<span class="hljs-string">&quot;The coremod %s does not contain a valid jar manifest- it will be ignored&quot;</span>, coreMod.getName());
  <span class="hljs-keyword">continue</span>;
}
</code></pre>
</li>
<li><p>&#x5C06;CoreMod&#x52A0;&#x5165;ClassPath&#xFF0C;&#x5E76;&#x83B7;&#x5F97;<code>IFMLLoadingPlugin</code>&#x5B9E;&#x4F8B;&#x52A0;&#x5165;&#x5217;&#x8868;<code>loadPlugins</code></p>
<pre><code class="lang-java">classLoader.addURL(coreMod.toURI().toURL());
...
Class&lt;?&gt; coreModClass = Class.forName(fmlCorePlugin, <span class="hljs-keyword">true</span>, classLoader);
...
IFMLLoadingPlugin plugin = (IFMLLoadingPlugin) coreModClass.newInstance();
loadPlugins.add(plugin);
</code></pre>
</li>
<li><p><code>handleLaunch</code>&#x65B9;&#x6CD5;&#xFF08;&#x957F;&#x5230;&#x53EF;&#x6015;&#xFF09;&#x4E2D;&#xFF0C;&#x904D;&#x5386;<code>loadPlugins</code>&#xFF0C;&#x5E76;&#x8C03;&#x7528;<code>getASMTransformerClass</code>&#x8BFB;&#x53D6;<code>IClassTransformer</code>&#x7684;&#x7C7B;&#xFF0C;&#x5E76;&#x52A0;&#x5165;&#x5230;<code>RelaunchClassLoader</code>&#x7684;<code>transformers</code>&#x4E2D;</p>
<pre><code class="lang-java"><span class="hljs-keyword">for</span> (IFMLLoadingPlugin plug : loadPlugins)
{
  <span class="hljs-keyword">if</span> (plug.getASMTransformerClass()!=<span class="hljs-keyword">null</span>)
  {
      <span class="hljs-keyword">for</span> (String xformClass : plug.getASMTransformerClass())
      {
          actualClassLoader.registerTransformer(xformClass);
      }
  }
}
</code></pre>
</li>
</ul>
<p>&#x5F53;&#x4E00;&#x4E2A;&#x7C7B;&#x88AB;&#x52A0;&#x8F7D;&#x65F6;&#xFF0C;<code>RelaunchClassLoader</code>&#x5C06;&#x4F1A;&#x8FDB;&#x884C;&#x5982;&#x4E0B;&#x64CD;&#x4F5C;&#xFF1A;</p>
<ul>
<li>&#x5728;<code>findClass</code>&#x65B9;&#x6CD5;&#x4E2D;&#xFF0C;&#x901A;&#x8FC7;<code>runTransformers</code>&#x95F4;&#x63A5;&#x9010;&#x4E2A;&#x8C03;&#x7528;<code>transforms</code><pre><code class="lang-java"><span class="hljs-keyword">byte</span>[] transformedClass = runTransformers(untransformedName, transformedName, basicClass);
</code></pre>
<pre><code class="lang-java"><span class="hljs-keyword">for</span> (IClassTransformer transformer : transformers)
{
  basicClass = transformer.transform(name, transformedName, basicClass);
}
</code></pre>
</li>
</ul>
<h1 id="&#x5236;&#x4F5C;&#x65B9;&#x6CD5;">&#x5236;&#x4F5C;&#x65B9;&#x6CD5;</h1>
<p>(&#x4EE5;&#x4E0B;&#x4EE3;&#x7801;&#x9002;&#x7528;&#x4E8E;1.3.2-1.5.2)</p>
<p>&#x901A;&#x8FC7;&#x5206;&#x6790;&#xFF0C;&#x6211;&#x4EEC;&#x786E;&#x5B9A;&#x4E86;&#x4E09;&#x4E2A;&#x5173;&#x952E;&#x4FE1;&#x606F;&#x2014;&#x2014;Manifest&#x3001;<code>IFMLLoadingPlugin</code>&#x4E0E;<code>IClassTransformer</code>&#xFF0C;&#x4EE5;&#x4E0B;&#x9010;&#x4E2A;&#x4ECB;&#x7ECD;&#x3002;</p>
<h2 id="manifest">Manifest</h2>
<p>Manifest&#x6709;&#x6E05;&#x5355;&#x7684;&#x610F;&#x601D;&#xFF0C;&#x5728;&#x8FD9;&#x91CC;&#x6307;&#x7684;&#x662F;jar&#x4E2D;&#x7684;<code>META-INF/MANIFEST.MF</code>&#x6587;&#x4EF6;&#xFF0C;&#x9700;&#x8981;&#x5728;&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#x4E2D;&#x52A0;&#x5165;&#x5982;&#x4E0B;&#x5185;&#x5BB9;&#xFF1A;</p>
<pre><code>FMLCorePlugin: com.example.ExamplePlugin
</code></pre><ul>
<li><code>FMLCorePlugin</code>&#x5C5E;&#x6027;&#x6307;&#x5B9A;&#x4E86;<code>IFMLLoadingPlugin</code>&#x7684;&#x7C7B;&#x540D;</li>
</ul>
<h2 id="ifmlloadingplugin">IFMLLoadingPlugin</h2>
<p><code>IFMLLoadingPlugin</code>&#x662F;FML&#x63D0;&#x4F9B;&#x7684;&#x4E00;&#x4E2A;&#x63A5;&#x53E3;&#xFF0C;&#x9700;&#x8981;&#x5B9E;&#x73B0;&#x4EE5;&#x4E0B;&#x51E0;&#x4E2A;&#x65B9;&#x6CD5;&#xFF1A;</p>
<ul>
<li><code>getLibraryRequestClass</code>&#xFF0C;&#x8FD4;&#x56DE;&#x4F9D;&#x8D56;&#x7C7B;</li>
<li><code>getASMTransformerClass</code>&#xFF0C;&#x8FD4;&#x56DE;<code>IClassTransformer</code>&#x7684;&#x5B8C;&#x6574;&#x7C7B;&#x540D;&#x6784;&#x6210;&#x7684;&#x6570;&#x7EC4;&#xFF0C;&#x8FD9;&#x662F;CoreMod&#x7684;&#x5173;&#x952E;</li>
<li><code>getSetupClass</code>&#xFF0C;&#x8FD4;&#x56DE;<code>IFMLCallhook</code>&#x7684;&#x5B9E;&#x73B0;&#x7C7B;</li>
<li><code>injectData</code>,&#x53EF;&#x4EE5;&#x83B7;&#x5F97;<code>mcLocation</code>&#x3001;<code>coremodList</code>&#x4E0E;<code>coremodLocation</code>&#xFF0C;&#x5206;&#x522B;&#x662F;Minecraft&#x6587;&#x4EF6;&#x5939;<code>File</code>&#x3001;CoreMod&#x5217;&#x8868;<code>List</code>&#x3001;&#x5F53;&#x524D;CoreMod&#x6587;&#x4EF6;<code>File</code>&#x3002;&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;&#x4E0E;<code>IFMLCallhook</code>&#x4E2D;&#x7684;<code>injectData</code>&#x4E3B;&#x8981;&#x533A;&#x522B;&#x4E3A;&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;&#x662F;&#x5728;Minecraft&#x542F;&#x52A8;&#x540E;&#x8C03;&#x7528;&#x7684;&#xFF0C;&#x53EF;&#x4EE5;&#x64CD;&#x4F5C;Minecraft&#x7684;class</li>
</ul>
<p>&#x540C;&#x65F6;&#xFF0C;&#x63D0;&#x4F9B;&#x4E86;&#x4EE5;&#x4E0B;&#x51E0;&#x4E2A;&#x6CE8;&#x89E3;&#x6765;&#x8FDB;&#x884C;&#x4FE1;&#x606F;&#x8865;&#x5145;&#xFF1A;</p>
<ul>
<li><code>TransformerExclusions</code>&#xFF0C;&#x6307;&#x5B9A;&#x4E0D;&#x88AB;CoreMod&#x4FEE;&#x6539;&#x7684;&#x5305;&#x540D;&#x524D;&#x7F00;&#x6570;&#x7EC4;&#xFF0C;&#x4F8B;&#x5982;&#x6307;&#x5B9A;&#x4E86;<code>com.example</code>&#x540E;&#xFF0C;<code>com.example.something.Example</code>&#x4E5F;&#x4E0D;&#x4F1A;&#x88AB;&#x4FEE;&#x6539;</li>
<li><code>MCVersion</code>&#xFF0C;&#x6307;&#x5B9A;CoreMod&#x9002;&#x7528;&#x7684;Minecraft&#x7248;&#x672C;</li>
</ul>
<p>&#x4E00;&#x4E2A;&#x7B80;&#x5355;&#x7684;<code>IFMLLoadingPlugin</code>&#x5B9E;&#x73B0;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-java"><span class="hljs-keyword">package</span> com.example;

<span class="hljs-keyword">import</span> java.util.Map;

<span class="hljs-keyword">import</span> cpw.mods.fml.relauncher.IFMLLoadingPlugin;

<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ExamplePlugin</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">IFMLLoadingPlugin</span> </span>{

    <span class="hljs-meta">@Override</span>
    <span class="hljs-keyword">public</span> String[] getLibraryRequestClass() {
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">null</span>;
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-keyword">public</span> String[] getASMTransformerClass() {
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> String[]{<span class="hljs-string">&quot;com.example.ClassTransformer&quot;</span>};
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">getModContainerClass</span><span class="hljs-params">()</span> </span>{
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">null</span>;
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> String <span class="hljs-title">getSetupClass</span><span class="hljs-params">()</span> </span>{
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">null</span>;
    }

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">injectData</span><span class="hljs-params">(Map&lt;String, Object&gt; data)</span> </span>{
    }

}
</code></pre>
<h2 id="iclasstransformer">IClassTransformer</h2>
<p><code>IClassTransformer</code>&#x662F;FML&#x63D0;&#x4F9B;&#x7684;&#x63A5;&#x53E3;&#xFF0C;&#x9700;&#x8981;&#x5B9E;&#x73B0;&#x4EE5;&#x4E0B;&#x65B9;&#x6CD5;&#xFF1A;</p>
<ul>
<li><code>transform</code>&#xFF0C;&#x63A5;&#x6536;<code>name</code>&#x3001;<code>transformedName</code>&#x548C;<code>bytes</code>&#x4E09;&#x4E2A;&#x53C2;&#x6570;&#xFF0C;&#x5206;&#x522B;&#x662F;&#x539F;&#x7C7B;&#x540D;&#x3001;mcp&#x65E0;&#x6DF7;&#x6DC6;&#x7C7B;&#x540D;&#x548C;class&#x6587;&#x4EF6;&#x7684;<code>byte</code>&#x6570;&#x7EC4;&#xFF0C;&#x9700;&#x8981;&#x8FD4;&#x56DE;&#x4FEE;&#x6539;&#x540E;&#x7684;class&#x6587;&#x4EF6;&#x7684;<code>byte</code>&#x6570;&#x7EC4;</li>
</ul>
<p>&#x9700;&#x8981;&#x7279;&#x522B;&#x6CE8;&#x610F;&#x7684;&#x662F;&#xFF1A;</p>
<ul>
<li><code>name</code>&#x539F;&#x7C7B;&#x540D;&#x548C;<code>bytes</code> class&#x6587;&#x4EF6;&#xFF0C;&#x5728;&#x6E38;&#x620F;&#x8FD0;&#x884C;&#x65F6;&#x4E3A;notch&#x6DF7;&#x6DC6;&#xFF0C;&#x5F00;&#x53D1;&#x73AF;&#x5883;&#x6D4B;&#x8BD5;&#x65F6;&#x4E3A;mcp&#x6DF7;&#x6DC6;</li>
<li><code>bytes</code>&#x53EF;&#x80FD;&#x5DF2;&#x88AB;&#x5176;&#x4ED6;CoreMod&#x751A;&#x81F3;Forge&#x672C;&#x8EAB;&#x4FEE;&#x6539;&#x8FC7;</li>
<li>&#x5207;&#x8BB0;&#x65E0;&#x8BBA;&#x5982;&#x4F55;&#x90FD;&#x8981;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x6709;&#x6548;&#x7684;<code>byte</code>&#x6570;&#x7EC4;&#xFF0C;&#x5426;&#x5219;&#x4F1A;&#x5BFC;&#x81F4;<code>ClassNotFoundException</code>&#x3001;<code>NoClassDefFoundError</code>&#x7B49;&#x5BFC;&#x81F4;&#x7684;&#x5D29;&#x6E83;</li>
</ul>
<p>&#x4E00;&#x4E2A;&#x6CA1;&#x6709;&#x5BF9;class&#x8FDB;&#x884C;&#x4EFB;&#x4F55;&#x4FEE;&#x6539;&#x7684;<code>IClassTransformer</code>&#x5B9E;&#x73B0;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-java"><span class="hljs-keyword">package</span> com.example;

<span class="hljs-keyword">import</span> cpw.mods.fml.relauncher.IClassTransformer;

<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ClassTransformer</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">IClassTransformer</span> </span>{
    <span class="hljs-keyword">public</span> <span class="hljs-keyword">byte</span>[] transform(String name, String transformedName, <span class="hljs-keyword">byte</span>[] bytes) {
        <span class="hljs-keyword">return</span> bytes;<span class="hljs-comment">//&#x7279;&#x522B;&#x6CE8;&#x610F;&#x9700;&#x8981;&#x8FD4;&#x56DE;bytes</span>
    }
}
</code></pre>
<p>&#x4E00;&#x4E2A;&#x5BF9;<code>net.minecraft.src.GuiPlayerTabOverlay</code>&#x7684;<code>a</code>(notch)&#x65B9;&#x6CD5;&#x8FDB;&#x884C;&#x4FEE;&#x6539;&#x7684;&#x5B9E;&#x4F8B;&#xFF1A;</p>
<pre><code class="lang-java"><span class="hljs-keyword">package</span> com.example;

<span class="hljs-keyword">import</span> cpw.mods.fml.relauncher.IClassTransformer;

<span class="hljs-keyword">import</span> org.objectweb.asm.ClassReader;
<span class="hljs-keyword">import</span> org.objectweb.asm.ClassWriter;
<span class="hljs-keyword">import</span> org.objectweb.asm.tree.ClassNode;
<span class="hljs-keyword">import</span> org.objectweb.asm.tree.MethodNode;

<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ClassTransformer</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">IClassTransformer</span> </span>{
    <span class="hljs-keyword">public</span> <span class="hljs-keyword">byte</span>[] transform(String name, String transformedName, <span class="hljs-keyword">byte</span>[] bytes) {
        <span class="hljs-keyword">if</span> (!<span class="hljs-string">&quot;net.minecraft.src.GuiPlayerTabOverlay&quot;</span>.equals(transformedName))
            <span class="hljs-keyword">return</span> bytes;

        <span class="hljs-comment">//&#x4F7F;&#x7528;ASM&#x8BFB;&#x5165;bytes</span>
        ClassReader cr = <span class="hljs-keyword">new</span> ClassReader(bytes);
        ClassNode cn = <span class="hljs-keyword">new</span> ClassNode();
        cr.accept(cn, <span class="hljs-number">0</span>);

        <span class="hljs-comment">//&#x904D;&#x5386;methods</span>
        <span class="hljs-keyword">for</span> (MethodNode mn : cn.methods) {
            <span class="hljs-keyword">if</span>(!<span class="hljs-string">&quot;a&quot;</span>.equals(mn.name)) 
                <span class="hljs-keyword">continue</span>;

            <span class="hljs-comment">//<span class="hljs-doctag">TODO:</span> &#x5728;&#x8FD9;&#x91CC;&#x8FDB;&#x884C;ASM&#x64CD;&#x4F5C;</span>
        }

        <span class="hljs-comment">//&#x8FD4;&#x56DE;&#x4FEE;&#x6539;&#x540E;&#x7684;bytes</span>
        ClassWriter cw = <span class="hljs-keyword">new</span> ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
        cn.accept(cw);
        <span class="hljs-keyword">return</span> cw.toByteArray();
    }
}
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                
                <a href="4.2.html" class="navigation navigation-next navigation-unique" aria-label="Next page: 1.6.1-1.12.2">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"1.3.2-1.5.2","level":"1.7.1","depth":2,"next":{"title":"1.6.1-1.12.2","level":"1.7.2","depth":2,"path":"4.2.md","ref":"4.2.md","articles":[]},"previous":{"title":"4 FML CoreMod","level":"1.7","depth":1,"ref":"","articles":[{"title":"1.3.2-1.5.2","level":"1.7.1","depth":2,"path":"4.1.md","ref":"4.1.md","articles":[]},{"title":"1.6.1-1.12.2","level":"1.7.2","depth":2,"path":"4.2.md","ref":"4.2.md","articles":[]},{"title":"1.13.2-1.14.4","level":"1.7.3","depth":2,"path":"4.3.md","ref":"4.3.md","articles":[]}]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"4.1.md","mtime":"2019-03-09T13:43:50.506Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-09-08T04:47:05.818Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

